FROM golang:1.24rc1-alpine3.20 AS app-builder

COPY . /root/app

WORKDIR /root/app/cmd
RUN CGO_ENABLED=0 GO111MODULE=on GOOS=linux GOARCH=amd64 GOFLAGS=-mod=vendor go build -ldflags '-w -s' -o run ../main.go

FROM alpine:3.20.3

COPY --from=app-builder /root/app/cmd/run /root/app/run
COPY --from=app-builder /root/app/config/ /root/app/config/
RUN chmod +x /root/app/run

WORKDIR /root/app

CMD ["/root/app/run", "--dir", "/root/app/"]
